package com.softserveinc.interactive_board.validators.form;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;

import com.softserveinc.interactive_board.domain.User;
import com.softserveinc.interactive_board.domain.UserType;


public class EditUserForm {
	
	public EditUserForm(Long id, String login, String password, int userTypeId,
			String email, String skype, String summary) {
		super();
		this.id = id;
		this.login = login;
		this.password = password;
		this.userTypeId = userTypeId;
		this.email = email;
		this.skype = skype;
		this.summary = summary;
	}

	public EditUserForm(Long id, String login, String password, int userTypeId) {
		this(id, login, password, userTypeId, "", "", "");
	}
	
	public EditUserForm(final User user) {
		super();
		this.id = user.getId();
		this.login = user.getLogin();
		this.password = user.getPassword();
		this.userTypeId = user.getUserType().getId();
		this.email = user.getEmail();
		this.skype = user.getSkype();
		this.summary = user.getSummary();
	}
	
	public EditUserForm() {
		this(new Long(0), "login", "password", UserType.ID_STUDENT);
	}
	
	public User getUser() {
		return new User(this.id, this.login, this.password, new UserType(this.userTypeId), this.email, this.skype, this.summary);
	}
	
	private Long id;

	@NotEmpty
	@Size(max = User.COLUMNS_MAX_LENGTH)
	@Pattern(regexp = "([A-Z]|[a-z])([A-Z]|[a-z]|[0-9])*")
	private String login;
	
	@NotEmpty
	@Size(max = User.COLUMNS_MAX_LENGTH)
	@Pattern(regexp = "([A-Z]|[a-z]|[0-9])*")
	private String password;
	
	@Min(UserType.ID_MIN_VALUE)
	@Max(UserType.ID_MAX_VALUE)
	private int userTypeId;

	@Size(max = User.COLUMNS_MAX_LENGTH)
	@Email
	private String email;
	
	@Size(max = User.COLUMNS_MAX_LENGTH)
	private String skype;
	

	@Size(max = User.SUMMARY_COLUMN_MAX_LENGTH)
	private String summary;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public int getUserTypeId() {
		return userTypeId;
	}

	public void setUserTypeId(int userTypeId) {
		this.userTypeId = userTypeId;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getSkype() {
		return skype;
	}

	public void setSkype(String skype) {
		this.skype = skype;
	}

	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

}
